#include<iostream>
#include<string>
#include<map>
#include<fstream>
#include<sstream>
using std::endl;
using std::cout;
using std::map;
using std::string;
using std::ifstream;
using std::ofstream;
using std::istringstream;
void test0(){
    string s1 = "this is world";
    s1 = s1 + " world";
    cout<<s1.c_str()<<endl;
}

void test2(){
    map<int,string> _rule = {{1,"key"},{2,"help"},{6,"wangdao"},{4,"thank"},{3,"Init"}};
    _rule[1]+=" help";
    for(auto &ele:_rule){
        cout<<ele.first<<" "<<ele.second<<endl;
    }
    cout<<endl;
}
void test3(){
    string line = "brb be right back";
    istringstream iss(line);
    map<string,string> test;
    string world;
    string key;
    iss>>world;
    std::getline(iss,key);
    test={{world,key}};
        for(auto &ele:test){
        cout<<ele.first<<" "<<ele.second<<endl;
    }
    cout<<endl;
}

void makeRule(const string &line,map<string,string> &_map_rule){
    string key;
    string value;
    istringstream iss(line);
    while(iss >> key && getline(iss,value)){
        //读的第一个单词，作为key
        _map_rule.insert(make_pair(key,value));
    }
}
void test4(){
    string Line;
    map<string,string> _map_rule;
    ifstream ifs("map.txt");
    while(std::getline(ifs,Line)){
        makeRule(Line,_map_rule);
    }
    for(auto &ele : _map_rule){
        cout<<ele.first<<" "<<ele.second<<endl;
    }
}

int main(void){
    test4();
}